package com.zb.controller;

import com.zb.entity.Student;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class ItemController {

    @RequestMapping("/show")
    public String show(Model model) {
        System.out.println("进入控制器...");
        model.addAttribute("msg", "一条测试内容");
        Student student = new Student(1, "张三", 20);
        model.addAttribute("stu", student);
        Student student1 = new Student(1, "张三1", 21);
        Student student2 = new Student(2, "张三2", 25);
        Student student3 = new Student(3, "张三3", 28);

        List<Student> list = new ArrayList<>();
        list.add(student1);
        list.add(student2);
        list.add(student3);
        model.addAttribute("stuList", list);

        model.addAttribute("tag","<a href='www.baidu.com'>百度</a>");
        Map<String,Student> map = new HashMap<>();
        map.put("one",student1);
        map.put("two",student2);
        map.put("three",student3);
        model.addAttribute("stuMap", map);
        return "/index";
    }
}
